<template>
  <div>
    <ul>
      <li v-for="(item,index) in arr" :key="index">
        {{ item }}
        <button @click="delBtn(index)">删除</button>
      </li>

      <button @click="addFn" style="margin-top: 10px">生成</button>
    </ul>
  </div>
</template>

<script>
export default {
   data() {
    return {
      arr:[1,5,3]
    }
   },
   methods:{
    addFn(){
      this.arr.push(Math.floor(Math.random() * 10))
    },
    delBtn(ind) {
      // console.log(ind);
      this.arr.splice(ind,1)
    } 
   }
}
</script>

<style>

</style>